package com.qf.service.impl;

import com.qf.entity.SysOrder;
import com.qf.entity.SysOrderDTO;
import com.qf.entity.SysOrderVO;
import com.qf.mapper.SysOrderMapper;
import com.qf.service.SysOrderService;
import com.qf.util.AliyunOSSUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * --- 冲 ---
 *
 * @author Biggen
 * @date 2025/4/29
 * @desc
 */
@Service
public class SysOrderServiceImpl implements SysOrderService {

    @Autowired
    private SysOrderMapper mapper;
    @Override
    public boolean SysOrderDelete(int id) {
        return mapper.SysOrderDelete(id);
    }

    @Override
    public List<SysOrderVO> queryAllSysOrderPage(SysOrderDTO sysOrderDTO) {
        return mapper.queryAllSysOrderPage(sysOrderDTO);
    }

    @Override
    public boolean SysOrderDeleteAll(List<Integer> ids) {
        return mapper.SysOrderDeleteAll(ids);
    }

    @Override
    public boolean SysOrderUpdate(SysOrder sysOrder) {
        return mapper.SysOrderUpdate(sysOrder);
    }

    @Override
    public boolean SysOrderAdd(SysOrder sysOrder) {
        return mapper.SysOrderAdd(sysOrder);
    }

    @Override
    public String SysOrderImgUpload(MultipartFile file, String orderId) {
        // 上传图片到OSS,获取图片相对路径
        String relativePath = AliyunOSSUtil.upLoad(file);
        // 更新到数据库
        // boolean isUpdated = mapper.updateImgByOrderId(orderId, relativePath);
        // if (!isUpdated){
        //     throw new RuntimeException("更新图片路径失败");
        // }
        return relativePath;
    }

    @Override
    public String SysOrderImgUpload2(MultipartFile file, String orderId) {
        // 上传图片到OSS,获取图片相对路径
        // String relativePath = AliyunOSSUtil.upLoad(file);
        // 更新到数据库
        // boolean isAdd = mapper.addImgByOrderId(orderId, relativePath);
        // if (!isAdd){
        //     throw new RuntimeException("更新图片路径失败");
        // }
        return null;
    }


}
